import React from 'react';
import ReactDOM from 'react-dom';
import { Table, Icon } from 'antd';
import ajax from '../../../utils/ajax';

//生成表格列信息
const columns = [{
  title: '预约类型',
  dataIndex: 'orderType',
  key: 'orderType',
  render:(text, record) => {
      if(text==100){
       return "场馆预约"
      }else if (text==101) {
        return "活动预约"
      }else{
        return "电影预约"
      }
  }
}, {
  title: '预约场次',
  dataIndex: 'disparkSeasonInfo',
  key: 'disparkSeasonInfo',
}, {
  title: '预约人数',
  dataIndex: 'personCount',
  key: 'personCount',
}, {
  title: '预约信息',
  dataIndex: 'appointmentContactsStr',
  key: 'appointmentContactsStr',

}];

//存放表格数据
const Reportdata=[];
const paramData={};

/**
 * 报表表格组件
 */
class ReportTable extends React.Component {
  constructor(props) {
    super(props);
    this.initZssData();
  }

   state = {
      width: 500,
      height: 450,
      plotCfg: {
        margin: [50, 100, 50, 120],
      },
      forceFit: true, //自适应
      nowDay:new Date().format('yyyyMMdd'),//现在时间
  };

 //初始化数据
 initZssData(){
    var self = this;
    //const paramData={museumId:'1vfha',day:'20170429'};
     paramData.day=this.state.nowDay;
    const url = '/statistic/getMuseumGroupAppointmentOrderInfo';
      ajax.post({
      url: url,
      async: false,//必须用同步请求，否则数据显示异常
      params:paramData,
      success: function (res) {
        for(var i=0;i<res.data.length;i++){
           var tmp={};
           tmp.key=i+1;
           tmp.orderType=res.data[i].orderType;
           tmp.personCount=res.data[i].personCount;
           tmp.disparkSeasonInfo=res.data[i].disparkSeasonInfo;
           tmp.appointmentContactsStr=res.data[i].appointmentContactsStr;
           Reportdata.push(tmp);
         }
      }
    })
  }

   render(){return (
       <Table 
          columns={columns} 
          dataSource={Reportdata}
          />
       );}
}

export default ReportTable;